package priv.abadstring.study.haoke.webapi.manage.graphql;

import graphql.schema.DataFetchingEnvironment;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import priv.abadstring.study.haoke.webapi.manage.HouseLocationManageByMongo;
import priv.abadstring.study.haoke.webapi.vo.map.MapHouseDataResult;

/**
 * MapHouseDataFetcher
 *
 * @author aBadString
 * @date 2021-08-05 16:52:40
 */
@Component
public class MapHouseDataFetcher implements DataFetcherSpecification<MapHouseDataResult> {
    @Autowired
    private HouseLocationManageByMongo houseLocationManageByMongo;

    @Override
    public String fieldName() {
        return "MapHouseData";
    }

    @Override
    public MapHouseDataResult dataFetcher(DataFetchingEnvironment args) {
        Double lng = args.getArgument("lng");
        Double lat = args.getArgument("lat");
        Integer zoom = args.getArgument("zoom");
        System.out.println(lng + ", " + lat + ", " + zoom);
        return houseLocationManageByMongo.queryHouseData(lng, lat, zoom);

        // List<MapHouseXY> list = new ArrayList<>(11);
        // list.add(new MapHouseXY(116.43244f,39.929986f));
        // list.add(new MapHouseXY(116.424355f,39.92982f));
        // list.add(new MapHouseXY(116.423349f,39.935214f));
        // list.add(new MapHouseXY(116.350444f,39.931645f));
        // list.add(new MapHouseXY(116.351684f,39.91867f));
        // list.add(new MapHouseXY(116.353983f,39.913855f));
        // list.add(new MapHouseXY(116.357253f,39.923152f));
        // list.add(new MapHouseXY(116.349168f,39.923152f));
        // list.add(new MapHouseXY(116.36232f,39.938339f));
        // list.add(new MapHouseXY(116.374249f,39.94625f));
        // list.add(new MapHouseXY(116.380178f,39.953053f));
        // return new MapHouseDataResult(list);
    }
}
